﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="CheckNameProject._Default" %>


<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>


<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script src="Scripts/MyScript.js" type="text/javascript"></script>
    <style type="text/css">
        .style3
        {
        }
        .style4
        {
            width: 96px;
            height: 26px;
        }
        .style5
        {
            height: 26px;
        }
        .style7
        {
        }
        .style8
        {
            width: 365px;
        }
        .style9
        {
            width: 369px;
        }
        .style10
        {
            width: 490px;
        }
    </style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    
   
    <div>
    
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
    
    
    </div>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
            SelectCommand="SELECT DocumentID, DocumentName, Path, DateUpload, StatusID, CONVERT (VARCHAR(24), Date, 103) AS Date FROM [Document] ORDER BY Date DESC">
        </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDocIncomplete" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        
        SelectCommand="SELECT * FROM [Document] WHERE ([StatusID] = @StatusID) ORDER BY [DocumentID] DESC">
        <SelectParameters>
            <asp:Parameter DefaultValue="0" Name="StatusID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDocComplete" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        
        SelectCommand="SELECT * FROM [Document] WHERE ([StatusID] = @StatusID) ORDER BY [DocumentID] DESC">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="StatusID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <table style="width: 100%;">
        <tr>
            <td class="style7" style="color: #000000" align="right" colspan="3">
                
                [ มี&nbsp;
                <asp:Label ID="lblCount" runat="server" Text="?"></asp:Label>
&nbsp;คำสั่งที่ยังไม่ได้เพิ่มบุคลากร ]</td>
        </tr>
        <tr>
            <td class="style8" style="color: #000000">
                
                &nbsp;</td>
            <td class="style9" style="color: #000000">
                
                &nbsp;</td>
            <td style="color: #000000" align="right">
                รูปแบบ :
                
                <asp:DropDownList ID="cbSort" runat="server" Height="22px" Width="95px" 
                    AutoPostBack="True" onselectedindexchanged="cbSort_SelectedIndexChanged">
                    <asp:ListItem Value="2">ทั้งหมด</asp:ListItem>
                    <asp:ListItem Value="0">คำสั่งที่ยังไม่สมบูรณ์</asp:ListItem>
                    <asp:ListItem Value="1">คำสั่งที่เพิ่มสมบูรณ์แล้ว</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        </table>
    <table style="width: 100%;" bgcolor="#FFFF66">
        <tr>
            <td class="style10" style="color: #000000">
                
                &nbsp;</td>
            <td class="style9" style="color: #000000">
                
                &nbsp;</td>
            <td style="color: #000000" align="left">
                
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style10" style="color: #000000">
                
                <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                    <ContentTemplate>
                        &nbsp;&nbsp;&nbsp;&nbsp; ชื่อคำสั่ง :
                        <asp:TextBox ID="txtDocName" runat="server" Width="400px" Height="18px"></asp:TextBox>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
                
            </td>
            <td class="style9" style="color: #000000">
                
                <asp:UpdatePanel ID="UpdatePanel6" runat="server">
                    <ContentTemplate>
                        วันที่ :
                        <asp:TextBox ID="txtBeginDate" runat="server" Width="120px"></asp:TextBox>
                        <asp:CalendarExtender ID="txtBeginDate_CalendarExtender" runat="server" 
                            Format="dd/MM/yyyy" PopupButtonID="imbCalBegin" TargetControlID="txtBeginDate">
                        </asp:CalendarExtender>
                        <asp:ImageButton ID="imbCalBegin" runat="server" ImageAlign="AbsBottom" 
                            ImageUrl="~/Image/Icon/calendar.gif" />
                        &nbsp;ถึง&nbsp;<asp:TextBox ID="txtFinishDate" runat="server" Width="120px"></asp:TextBox>
                        <asp:CalendarExtender ID="txtFinishDate_CalendarExtender" runat="server" 
                            Format="dd/MM/yyyy" PopupButtonID="imbCalFinish" 
                            TargetControlID="txtFinishDate">
                        </asp:CalendarExtender>
                        <asp:ImageButton ID="imbCalFinish" runat="server" ImageAlign="AbsBottom" 
                            ImageUrl="~/Image/Icon/calendar.gif" />
                    </ContentTemplate>
                </asp:UpdatePanel>
                
            </td>
            <td style="color: #000000" align="left">
                
    <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" 
        Text="ค้นหา" />
            </td>
        </tr>
        </table>
        <asp:UpdatePanel ID="UpdatePanel4" runat="server">
            <ContentTemplate>
                <asp:GridView ID="gvDoc" runat="server" CellPadding="4" ForeColor="#333333" 
        GridLines="None" AllowSorting="True" AutoGenerateColumns="False" 
        DataKeyNames="DocumentID" Width="100%" AllowPaging="True" 
                    onpageindexchanging="gvDoc_PageIndexChanging" 
                    onrowdatabound="gvDoc_RowDataBound" onrowdeleting="gvDoc_RowDeleting">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:TemplateField InsertVisible="False" SortExpression="DocumentID">
                            <EditItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("DocumentID") %>'></asp:Label>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("DocumentID") %>'  />
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="1px" />
                            <ItemStyle HorizontalAlign="Center" Width="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="คำสั่ง" SortExpression="DocumentName">
                            <ItemTemplate>
                                <asp:HyperLink ID="HyperLink1" runat="server" 
                        NavigateUrl='<%# Eval("DocumentID", "~/Checkname.aspx?ID={0}") %>' 
                        Text='<%# Eval("DocumentName") %>'></asp:HyperLink>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DocumentName") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="72%" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="Date" HeaderText="วันที่เข้าประชุม" 
                SortExpression="Date" DataFormatString="{0:d}">
                        <HeaderStyle HorizontalAlign="Center" Width="20%" />
                        <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" 
                                    CommandName="Delete" ImageUrl="~/Image/delete_icon.gif" Text="Delete" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#2461BF" />
                    <EmptyDataTemplate>
                        <asp:Panel ID="Panel1" runat="server" BackColor="#FFFF66" 
                            HorizontalAlign="Center">
                            <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Medium" 
                                ForeColor="Red" Text="ไม่มีคำสั่งค่ะ"></asp:Label>
                        </asp:Panel>
                    </EmptyDataTemplate>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerSettings Mode="NextPreviousFirstLast" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="gvDoc" EventName="PageIndexChanging" />
            </Triggers>
    </asp:UpdatePanel>
        <br />
    <br />
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Panel ID="panAddDoc" runat="server" Width="100%">
                <table style="width:100%;" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="left" class="style3" width="8%" bgcolor="Yellow">
                            ชื่อคำสั่ง</td>
                        <td width="62%" bgcolor="Yellow">
                            :
                            <asp:TextBox ID="txtAddDocName" runat="server" Width="90%" 
                                ValidationGroup="DocName"></asp:TextBox>
                            
                            <asp:RequiredFieldValidator ID="NReq" runat="server" 
                                ControlToValidate="txtAddDocName" Display="None" 
                                ErrorMessage="&lt;b&gt;กรุณาใสข้อมูล&lt;/b&gt;&lt;br /&gt;กรุณาใส่ชื่อคำสั่งที่ต้องการเพิ่ม" 
                                ValidationGroup="DocName"></asp:RequiredFieldValidator>
                            <asp:ValidatorCalloutExtender ID="NReq_ValidatorCalloutExtender" runat="server" 
                                PopupPosition="TopLeft" TargetControlID="NReq">
                            </asp:ValidatorCalloutExtender>
                            
                        </td>
                        <td width="12%" bgcolor="Yellow" align="right">
                            วันที่เข้าประชุม :&nbsp;&nbsp;
                        </td>
                        <td bgcolor="Yellow" width="20%">
                            <asp:TextBox ID="txtAddDate" runat="server" Width="80%"></asp:TextBox>
                            <asp:CalendarExtender ID="txtAddDate_CalendarExtender" runat="server" 
                                Format="dd/MM/yyyy" PopupButtonID="imbCal" TargetControlID="txtAddDate">
                            </asp:CalendarExtender>
                            <asp:ImageButton ID="imbCal" runat="server" ImageAlign="AbsBottom" 
                                ImageUrl="~/Image/Icon/calendar.gif" />
                            <asp:RequiredFieldValidator ID="DReq" runat="server" 
                                ControlToValidate="txtAddDate" Display="None" 
                                ErrorMessage="&lt;b&gt;กรุณาใสข้อมูล&lt;/b&gt;&lt;br /&gt;กรุณาใส่วันที่เข้าประชุมที่ต้องการเพิ่ม" 
                                ValidationGroup="DocName"></asp:RequiredFieldValidator>
                            <asp:ValidatorCalloutExtender ID="DReq_ValidatorCalloutExtender" runat="server" 
                                PopupPosition="TopLeft" TargetControlID="DReq">
                            </asp:ValidatorCalloutExtender>
                        </td>
                    </tr>
                    <tr>
                        <td align="left" class="style4" bgcolor="Yellow">
                            เลือกไฟล์</td>
                        <td class="style5" bgcolor="Yellow">
                            
                                :
                                <asp:FileUpload ID="FileUploadControl" runat="server" />
                        </td>
                        <td class="style5" bgcolor="Yellow">
                            &nbsp;</td>
                        <td bgcolor="Yellow" class="style5">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style3" align="right" colspan="4">
                            <br />
                            <asp:Button ID="btnConfirmDoc" runat="server" onclick="btnConfirmDoc_Click" 
                                Text="ยืนยัน" ValidationGroup="DocName" Width="70px" />
                            &nbsp;
                            <asp:Button ID="btnCancelDoc" runat="server" onclick="btnCancelDoc_Click" 
                                Text="ยกเลิก" Width="70px" />
                        </td>
                    </tr>

                </table>
                
            </asp:Panel>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAddDoc" EventName="Click" />
            <asp:PostBackTrigger ControlID="btnConfirmDoc" />
        </Triggers>
    </asp:UpdatePanel>
    
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
            <asp:Panel ID="panBtnAdd" runat="server" HorizontalAlign="Right">
                <asp:Button ID="btnAddDoc" runat="server" onclick="btnAddDoc_Click" 
                    Text="เพิ่มคำสั่ง" />
            </asp:Panel>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAddDoc" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
    <p align="right">&nbsp;</p>
    
</asp:Content>
